import Vue from 'vue';
import Router from 'vue-router';

import MainRouter from './MainRouter';
import CartRouter from './CartRouter';
import SpreadRouter from './SpreadRouter';
import UserRouter from './UserRouter';
import OrderRouter from './OrderRouter';

import Sale from './sale';
// import LoginTypes from '../assets/js/LoginStateTypes';
// import { Toast } from 'vant';
// import loginStore from '@/store/modules/login.js';

Vue.use(Router);

let routers = [];
routers = routers.concat(MainRouter, CartRouter, SpreadRouter, UserRouter, Sale, OrderRouter);
const router = new Router({
  mode: 'history',
  routes: routers
});
router.beforeEach((to, from, next) => {
  next();
  // alert('111' + to.name);
  // console.log(router, loginStore.state.loginState);
  // let notBind = LoginTypes.BLACK_LIST_NOT_BIND;
  // let notBuy = LoginTypes.BLACK_LIST_BIND;
  // switch (loginStore.state.loginState) {
  //   case LoginTypes.NEED_REGISTER:
  //     if (notBind.indexOf(to.name) >= 0) {
  //       next({name: 'register'});
  //     } else {
  //       next();
  //     }
  //     break;
  //   case LoginTypes.NEED_BIND_PHONE:
  //     if (notBuy.indexOf(to.name) >= 0) {
  //       next({name: 'register'});
  //     } else {
  //       next();
  //     }
  //     break;
  //   case LoginTypes.NEED_BUY:
  //     if (notBuy.indexOf(to.name) >= 0) {
  //       Toast('请先购买商品');
  //       next(false);
  //     } else {
  //       next();
  //     }
  //     break;
  //   case LoginTypes.LOGIN_ALL:
  //     next();
  //     break;
  //   case LoginTypes.ADMIN:
  //     next();
  //     break;
  // }
});
export default router;
